home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
57670
/
57670.xpi
/
chrome
/
content
/
options.js
< prev
next >
Wrap
Text File
|
2010-01-28
|
4KB
|
88 lines
function _(id) {return document.getElementById(id);}
function initialize_options() {
// initialize "% Scale" slider
_("scale").value = _("pref-scale").value
// Bind slider and textbox changes
_("scale").addEventListener("change", function(){_("scale-text").value = this.value}, false)
_("scale-text").addEventListener("change", function(){_("scale").value = this.value}, false)
// Disable/enable resize options as necessary
toggle_resize_options(!_("resize").checked)
// Disable/enable text options as necessary
toggle_text_options(!_("text-preview").checked)
// Hide/show resize options as necessary
_("resize-method").addEventListener("select", function(){change_resize_options(this.value)}, false)
change_resize_options(_("resize-method").value)
// Bind hover-zoom option controls
_("hover-zoom").addEventListener("mouseup", function(){_("hover-zoom-timeout").disabled = this.checked}, false)
_("hover-zoom-timeout").addEventListener("change", function(){_("pref-hover-zoom-timeout").value = this.value*1000}, false)
// Initialize hover-zoom-timeout
_("hover-zoom-timeout").disabled = !_("hover-zoom").checked
_("hover-zoom-timeout").value = _("pref-hover-zoom-timeout").value/1000.0
}
function log_(str) {
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage("CLPics: "+str);
}
function toggle_resize_options(disabled) {
if (!disabled) {
_("pref-resize-method").value = _("resize-method").value
}
var radios = _("resize-options").getElementsByTagName("radio")
var texts = _("resize-options").getElementsByTagName("textbox")
var scales = _("resize-options").getElementsByTagName("scale")
var checks = _("resize-options").getElementsByTagName("checkbox")
var labels = _("resize-options").getElementsByTagName("label")
for (var ix in radios) radios[ix].disabled = disabled
for (var ix in texts) texts[ix].disabled = disabled
for (var ix in scales) scales[ix].disabled = disabled
for (var ix in checks) checks[ix].disabled = disabled
for (var ix in labels) labels[ix].disabled = disabled
// h-z-t's disabled state depends secondarily on h-z's checked state
if (!disabled)
_("hover-zoom-timeout").disabled = !_("hover-zoom").checked
}
function toggle_image_options(disabled) {
if (!disabled)
toggle_resize_options(!_("resize").checked)
else
toggle_resize_options(true) // true = disabled
_("resize").disabled = disabled
var texts = _("image-options").getElementsByTagName("textbox")
var checks = _("image-options").getElementsByTagName("checkbox")
var labels = _("image-options").getElementsByTagName("label")
for (var ix in texts) texts[ix].disabled = disabled
for (var ix in checks) checks[ix].disabled = disabled
for (var ix in labels) labels[ix].disabled = disabled
}
function toggle_text_options(disabled) {
var texts = _("text-options").getElementsByTagName("textbox")
var checks = _("text-options").getElementsByTagName("checkbox")
var labels = _("text-options").getElementsByTagName("label")
for (var ix in texts) texts[ix].disabled = disabled
for (var ix in checks) checks[ix].disabled = disabled
for (var ix in labels) labels[ix].disabled = disabled
}
function change_resize_options(type) {
var blocks = {
"image_scale-options": _("image_scale-options"),
"image_maxheight-options": _("image_maxheight-options"),
"image_maxwidth-options": _("image_maxwidth-options")
}
for (var ix in blocks) blocks[ix].hidden = true
blocks[type+"-options"].hidden = false
}